package com.example.mywechat;

import android.app.Activity;
import android.content.IntentFilter;
import android.os.Bundle;

import androidx.annotation.Nullable;

public class BaseActivity extends Activity {
    private MyReceiver receiver;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        //将启动的Activity添加进来
        ActivityCollector.addActivity(this);
    }

    @Override
    protected void onDestroy() {
        ActivityCollector.removeActivity(this);
        super.onDestroy();
    }

    //注册广播
    @Override
    protected void onResume() {
        IntentFilter fliter=new IntentFilter();
        fliter.addAction("com.example.offLine");
        receiver=new MyReceiver();
        registerReceiver(receiver, fliter);
        super.onResume();
    }

    //注销广播
    @Override
    protected void onPause() {
        unregisterReceiver(receiver);
        super.onPause();
    }
}
